package com.bizihang.chain.support;

import com.bizihang.chain.Filter;
import com.bizihang.chain.FilterChain;

import java.util.List;

/**
 * @author 毕子航 951755883@qq.com
 * @date 2018/11/01
 */
public class ProxyFilterChain extends DefaultFilterChain {
	protected FilterChain originFilterChain;

	public ProxyFilterChain(FilterChain originFilterChain, List<Filter> filters) {
		super(filters);
		this.originFilterChain = originFilterChain;
	}

	@Override
	public void doFilter() {
		if (getFilters() == null || getPosition() == getFilters().size()) {
			originFilterChain.doFilter();
		} else {
			super.doFilter();
		}
	}
}
